<?
set_time_limit(9999999);
/***************************************************************************

*                            Dolphin Smart Community Builder

*                              -----------------

*     begin                : Mon Mar 23 2006

*     copyright            : (C) 2006 BoonEx Group

*     website              : http://www.boonex.com/

* This file is part of Dolphin - Smart Community Builder

*

* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. 

* http://creativecommons.org/licenses/by/3.0/

*

* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;

* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

* See the Creative Commons Attribution 3.0 License for more details. 

* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, 

* see license.txt file; if not, write to marketing@boonex.com

***************************************************************************/
 
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

echo "START .....<br /><br />";

echo "UPDATING DATABASE .....<br /><br />";
 
db_res("UPDATE `sys_modules` SET `version`='2.0.2' WHERE `uri` = 'location' AND `db_prefix` = 'modzzz_location_'");
 

db_res("DELETE FROM `modzzz_location_review` WHERE `location_id` NOT IN (SELECT `id` FROM `modzzz_location_main`)");


db_res("DELETE FROM `sys_options` WHERE `Name` = 'modzzz_location_any_add_subsection'"); 
$iCategId = (int)db_value("SELECT `id` FROM  `sys_options_cats` WHERE `name`='Location'");
db_res("  
INSERT INTO `sys_options` (`Name`, `VALUE`, `kateg`, `desc`, `Type`, `check`, `err_text`, `order_in_kateg`, `AvailableValues`) VALUES   
('modzzz_location_any_add_subsection', 'on', $iCategId, 'Allow any member to add sub-section (event,nightlife etc.) to a location', 'checkbox', '', '', '0', '') 
");
 

$aSub = array('event', 'shop', 'hotel', 'nightlife', 'school', 'service', 'transport', 'food');
for ($item = 0; $item < count($aSub)-1; $item++) {

	$fields = mysql_list_fields($db['db'], "modzzz_location_" . $aSub[$item] . "_main"); 
	$columns = mysql_num_fields($fields);
		   
	for ($i = 0; $i < $columns; $i++) {
		$field_array[] = mysql_field_name($fields, $i);
	}
		   
	if (!in_array('zip', $field_array)) {
		db_res("ALTER TABLE `modzzz_location_" . $aSub[$item] . "_main` ADD `zip` VARCHAR( 20 ) NOT NULL");  
	}

}

 

db_res("UPDATE `sys_pre_values` SET `Value`='S' WHERE `Key` IN ('LocationAccomodationAmenities','LocationAccomodationRoomAmenities','LocationCreditCards') AND `Value`='0'");




echo "SUCCESSFULLY UPDATED DATABASE ..... <br /><br />";
 

echo "FINISHED <br />";


?>